#include "datamsform.h"
#include "ui_datamsform.h"
#include <QSqlQueryModel>

#include <QDebug>

DataMSForm::DataMSForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::DataMSForm)
{
    ui->setupUi(this);

    m_datInfoModel = new QSqlQueryModel(this);
    updateDataView();
}

DataMSForm::~DataMSForm()
{
    delete ui;
}

void DataMSForm::updateDataView(void)
{
    m_datInfoModel->clear();
    m_datInfoModel->setQuery("select * from dat_info");
    m_datInfoModel->setHeaderData(0, Qt::Horizontal, tr("时间"));
    m_datInfoModel->setHeaderData(1, Qt::Horizontal, tr("温度"));
    m_datInfoModel->setHeaderData(2, Qt::Horizontal, tr("湿度"));
    m_datInfoModel->setHeaderData(3, Qt::Horizontal, tr("设备号"));

    ui->tableView->setModel(m_datInfoModel);
}
